/*
 *	test.cpp
 *
 *	Created on 3/1/2011 by Alan Mattila
 *	Test file for unit testing the Board class.
 */

#include <iostream>

#include "Board.h"
#include "Checkers.h"
#include "AIPathFinder.h"

using namespace std;


int main(int argc, char **argv)
{
	vector<MoveData*> data;
	Checkers checkers;

	cout << "Current Player: " << checkers.GetCurrentPlayer() << endl;
	cout << *(checkers.GetBoard());
	checkers.GetLegalMoves(data);

	int count = 1;
	while( checkers.GetStatus() == STATUS_IN_PROGRESS )
	{
		Path* path = checkers.GetBestPath();
		if( path )
		{
			// TEST - this is overkill since we already have the best path,
			// it just validates that you can use FindPathForMove() to insure
			// you really can get there from here.....
			path = checkers.FindPathForMove(path->GetPosition().GetX(),
											path->GetPosition().GetY(),
											path->GetPath()[0]->GetX(),
											path->GetPath()[0]->GetY());
			if( !checkers.FollowPath(path) )
			{
				break;
			}
		}

		count ++;
	}
	cout << "Game Status: " << checkers.GetStatus() << endl;
	cout << "Game Turns: " << count << endl;
	cout << *(checkers.GetBoard());
	system("pause");

	return 0;

	//vector<Path*> paths = checkers.GetMoves();
	//Path* path = checkers.GetBestPath();

	//AIPathFinder finder(checkers.GetCurrentPlayer(),checkers.GetBoard());
	//vector<Path*> paths = finder.GetPaths();

	//system("Pause");

	Checkers checkers2(checkers.GetStatus(), checkers.GetCurrentPlayer(), checkers.GetBoard());

	// Move one guy out for first player
	checkers.Move(2,5,3,4);
	cout << "Current Player: " << checkers.GetCurrentPlayer() << endl;
	cout << *(checkers.GetBoard());
	checkers.GetLegalMoves(data);
	// Move one guy out for second player
	checkers.Move(1,2,2,3);
	cout << "Current Player: " << checkers.GetCurrentPlayer() << endl;
	cout << *(checkers.GetBoard());
	checkers.GetLegalMoves(data);
	// Player 1 jumps player 2 guy 
	checkers.Move(3,4,1,2);
	cout << "Current Player: " << checkers.GetCurrentPlayer() << endl;
	cout << *(checkers.GetBoard());
	checkers.GetLegalMoves(data);
	// Player 2 jumps player 1 guy 
	checkers.Move(0,1,2,3);
	cout << "Current Player: " << checkers.GetCurrentPlayer() << endl;
	cout << *(checkers.GetBoard());
	checkers.GetLegalMoves(data);

	checkers.ClearLegalMoves(data);

	system("pause");

	return 0;
}


	//Board *board = new Board();
	//for(unsigned i=0; i<BOARD_Y; i++)
	//{
	//	for(unsigned j=0; j<BOARD_X; j++)
	//	{
	//		board->SetValue(j, i, (i*BOARD_Y + j));
	//	}
	//}
	//
	//cout << "Test: Here is a test array\n";
	//delete board;

	//board = checkers.GetBoard();
	//for(unsigned i=0; i<BOARD_Y; i++)
	//{
	//	for(unsigned j=0; j<BOARD_X; j++)
	//	{
	//		cout << board->GetValue(j, i) << " ";
	//	}
	//	cout << endl;
	//}

	//Board board2;
	//board2 = *(checkers.GetBoard());
	//board = 0;

